import {Controller, Get, Post, Body, Patch, Param, Delete, Query} from '@nestjs/common';
import { DiscussService } from './discuss.service';
import { CreateDiscussDto } from './dto/create-discuss.dto';
import {ApiOperation, ApiTags} from "@nestjs/swagger";
import {AllowAnon} from "../../common/decorators/allow-anon.decorator";
import {QueryAllDiscuss} from "./dto/query-all-discuss";
import {QueryBlogDiscuss} from "./dto/query-blog-discuss";
import {CreateMessageDto} from "./dto/create-message-dto";
@ApiTags('文章评论')
@Controller('discuss')
export class DiscussController {
  constructor(private readonly discussService: DiscussService) {}

  @AllowAnon()
  @Post('addDiscuss')
  @ApiOperation({ summary: '新增评论' })
  create(@Body() createDiscussDto: CreateDiscussDto) {
    return this.discussService.create(createDiscussDto);
  }

  @AllowAnon()
  @Post('addMessage')
  @ApiOperation({ summary: '新增留言' })
  addMessage(@Body() createMessageDto: CreateMessageDto) {
    return this.discussService.createMessage(createMessageDto);
  }

  @AllowAnon()
  @Get('getAllDiscuss')
  @ApiOperation({ summary: '获取评论' })
  getAllDiscuss(@Query() queryParams: QueryAllDiscuss) {
    return this.discussService.getAllDiscuss(queryParams);
  }

  @AllowAnon()
  @Get('getAllMessage')
  @ApiOperation({ summary: '获取留言' })
  getAllMessage(@Query() queryParams: QueryAllDiscuss) {
    return this.discussService.getAllMessage(queryParams);
  }

  @AllowAnon()
  @Get('getBlogDiscuss')
  @ApiOperation({ summary: '获取某个文章的评论' })
  getBlogDiscuss(@Query() queryParams: QueryBlogDiscuss) {
    return this.discussService.getBlogDiscuss(queryParams);
  }
}
